package com.shixun.entity;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by haiyan on 2016/12/11.
 */
@Entity
@Table(name = "user")
@Component
@Scope("prototype")
public class UserEntity {
    private String id;
    private String loginId;
    private String loginPass;
    private String name;
    private String sex;
    private String age;
    private String email;
    private Timestamp time;
    private String more1;
    private String more2;
    private String state;
    private Timestamp createtime;

    @Override
    public String toString() {
        return "UserEntity{" +
                "id='" + id + '\'' +
                ", loginId='" + loginId + '\'' +
                ", loginPass='" + loginPass + '\'' +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age='" + age + '\'' +
                ", email='" + email + '\'' +
                ", time=" + time +
                ", more1='" + more1 + '\'' +
                ", more2='" + more2 + '\'' +
                ", state='" + state + '\'' +
                ", createtime=" + createtime +
                '}';
    }

    public UserEntity(String id, String loginId, String loginPass, String name, String sex, String age, String email, Timestamp time, String more1, String more2, String state, Timestamp createtime) {
        this.id = id;
        this.loginId = loginId;
        this.loginPass = loginPass;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.email = email;
        this.time = time;
        this.more1 = more1;
        this.more2 = more2;
        this.state = state;
        this.createtime = createtime;
    }
    public UserEntity(){

    }
    /**
     * toXml return Map
     */
    public Map<String, Object> toMap() {
        Map<String, Object> voMap = new HashMap<>();
        voMap.put("id", id);
        voMap.put("loginId", loginId);
        voMap.put("loginPass", loginPass);
        voMap.put("name", name);
        voMap.put("sex", sex);
        voMap.put("age", age);
        voMap.put("time", TimeMaker.toDateTimeStr(time));
        voMap.put("email", email);
        voMap.put("more1", more1);
        voMap.put("more2", more2);
        voMap.put("createtime", TimeMaker.toDateTimeStr(createtime));
//        String aa = PowerMap.getPower("/BPaymentAction/jumpTab.action");
//        if (!Checks.empty(aa)) {
//            voMap.put("OperationCY_", aa);
//        }
        return voMap;
    }

    @GenericGenerator(name = "generator", strategy = "uuid")
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "Id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "loginId")
    public String getLoginId() {
        return loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }

    @Basic
    @Column(name = "loginPass")
    public String getLoginPass() {
        return loginPass;
    }

    public void setLoginPass(String loginPass) {
        this.loginPass = loginPass;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "sex")
    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Basic
    @Column(name = "age")
    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "time")
    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }

    @Basic
    @Column(name = "more1")
    public String getMore1() {
        return more1;
    }

    public void setMore1(String more1) {
        this.more1 = more1;
    }

    @Basic
    @Column(name = "more2")
    public String getMore2() {
        return more2;
    }

    public void setMore2(String more2) {
        this.more2 = more2;
    }

    @Basic
    @Column(name = "state")
    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Basic
    @Column(name = "createtime")
    public Timestamp getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Timestamp createtime) {
        this.createtime = createtime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserEntity that = (UserEntity) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (loginId != null ? !loginId.equals(that.loginId) : that.loginId != null) return false;
        if (loginPass != null ? !loginPass.equals(that.loginPass) : that.loginPass != null) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (sex != null ? !sex.equals(that.sex) : that.sex != null) return false;
        if (age != null ? !age.equals(that.age) : that.age != null) return false;
        if (email != null ? !email.equals(that.email) : that.email != null) return false;
        if (time != null ? !time.equals(that.time) : that.time != null) return false;
        if (more1 != null ? !more1.equals(that.more1) : that.more1 != null) return false;
        if (more2 != null ? !more2.equals(that.more2) : that.more2 != null) return false;
        if (state != null ? !state.equals(that.state) : that.state != null) return false;
        if (createtime != null ? !createtime.equals(that.createtime) : that.createtime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (loginId != null ? loginId.hashCode() : 0);
        result = 31 * result + (loginPass != null ? loginPass.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (sex != null ? sex.hashCode() : 0);
        result = 31 * result + (age != null ? age.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (time != null ? time.hashCode() : 0);
        result = 31 * result + (more1 != null ? more1.hashCode() : 0);
        result = 31 * result + (more2 != null ? more2.hashCode() : 0);
        result = 31 * result + (state != null ? state.hashCode() : 0);
        result = 31 * result + (createtime != null ? createtime.hashCode() : 0);
        return result;
    }


}
